package com.pvdnc.tapkit.chat.chat;

import com.pvdnc.encrypt.IEncrypt;
import com.pvdnc.encrypt.Xor;
import com.pvdnc.nsocket.EndPoint;
import com.pvdnc.nsocket.log.SLog;
import com.pvdnc.nsocket.protocol.base.Packet;
import com.pvdnc.nsocket.server.BaseServer;
import com.pvdnc.tapkit.chat.chat.client.KeyManager;
import com.pvdnc.tapkit.chat.chat.packet.ClientHello;
import com.pvdnc.tapkit.chat.chat.packet.InterpreterUtils;
import com.pvdnc.tapkit.chat.chat.packet.TextMessage;
import com.pvdnc.tapkit.chat.chat.server.OnClientClose;
import com.pvdnc.tapkit.chat.chat.server.OnClientHello;
import com.pvdnc.tapkit.chat.chat.server.OnClientIdle;
import com.pvdnc.tapkit.chat.chat.server.OnFriendRequest;
import com.pvdnc.tapkit.chat.chat.server.OnTextMessage;

import io.netty.channel.ChannelPipeline;

public class ChatServer extends BaseServer {
    private static final SLog LOG=new SLog(ChatServer.class);

    public KeyManager mRSAKeyManager=new KeyManager();

    public ChatServer(EndPoint endPoint, byte[] key) {
        super(endPoint,new Xor(key));
    }

    @Override
    public void onBind() {
        LOG.d("server bind");
    }

    @Override
    public void addWorkHandlers(ChannelPipeline pipeline) {
        pipeline.addLast(new OnClientHello(this));
        pipeline.addLast(new OnClientClose(this));
        pipeline.addLast(new OnTextMessage(this));
        pipeline.addLast(new OnFriendRequest(this));
        pipeline.addLast(new OnClientIdle(this));
    }

    @Override
    public Packet onPreClose() {
        return null;
    }
}
